package com.airsystem.pos.bengkel.entity;

import java.io.Serializable;
import java.util.Date;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinColumns;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.persistence.Transient;

import org.hibernate.annotations.ForeignKey;

/**
 * @author Budi Oktaviyan <budi.oktaviyan@icloud.com>
 */

@Entity
@Table(name = "tbl_order_layanan")
public class OrderLayanan implements Serializable {

	@Transient
	public static final String ALIAS = "order_layanan";

	@Id
	@GeneratedValue
	private Long id;

	@Temporal(TemporalType.DATE)
	private Date tanggal;

	@OneToMany(mappedBy = "order_layanan", fetch = FetchType.LAZY, cascade = { CascadeType.ALL }, orphanRemoval = true)
	private Set<DetailOrderLayanan> detail_order_layanan = new HashSet<DetailOrderLayanan>(0);

	@ManyToOne
	@JoinColumns({ @JoinColumn(name = "pelanggan_id", referencedColumnName = "pelanggan_id"),
				   @JoinColumn(name = "detail_kendaraan", referencedColumnName = "detail_kendaraan") })
	@ForeignKey(name = "FK_DETAIL_PELANGGAN")
	private DetailPelanggan detail_pelanggan;

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public Date getTanggal() {
		return tanggal;
	}

	public void setTanggal(Date tanggal) {
		this.tanggal = tanggal;
	}

	public Set<DetailOrderLayanan> getDetail_order_layanan() {
		return detail_order_layanan;
	}

	public void setDetail_order_layanan(Set<DetailOrderLayanan> detail_order_layanan) {
		this.detail_order_layanan = detail_order_layanan;
	}

	public void addDetail_order_layanan(DetailOrderLayanan detailOrderLayanan) {
		this.detail_order_layanan.add(detailOrderLayanan);
	}

	public DetailPelanggan getDetail_pelanggan() {
		return detail_pelanggan;
	}

	public void setDetail_pelanggan(DetailPelanggan detail_pelanggan) {
		this.detail_pelanggan = detail_pelanggan;
	}
}